﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogicServer.Users;
using Model;
using CommonCs;

namespace BugSysSolution
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            UserLogic ul = new UserLogic();
            String pwd = String.Empty;
            pwd = ul.GetPwdByUid(loginName.Text.ToLower().Trim());


            //登录成功 记录到session
            if (pwd == loginPwd.Text.Trim())
            {
                Session["user"] = ul.GetUserByUid(loginName.Text.Trim());
                Users user = Session["user"] as Users;
                Common.WriteFile(CommonCs.Exceptions.Operational, "登录提示", "用户[" + loginName.Text.ToLower().Trim() + "]登录成功!");
                Response.Redirect("Main.aspx");
            }
            else
            {
                Common.WriteFile(CommonCs.Exceptions.Operational, "登录提示", "用户[" + loginName.Text.ToLower().Trim() + "]登录失败!");
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "getpwderror", "alert('登录失败,请核对用户名和密码!');", true);
            }
        }
    }
}